#!/usr/bin/python
# coding=utf8
#
# Copyright (C) 2011 XNData contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


__author__ = "zhangchitc@gmail.com"


class SimpleNote:
    
    note_id = ""
    author_id = ""
    title = ""
    pub_time = None
    snippet = ""

    def __init__ (self, note_id = None, author_id = None, title = None, 
                    pub_time = None, snippet = None):
        self.note_id = note_id
        self.author_id = author_id
        self.title = title
        self.pub_time = pub_time

    def __repr__ (self):
        ret = ""
        ret += "note_id = %s\n" % self.note_id
        ret += "author_id = %s\n" % self.author_id
        ret += "title = %s\n" % self.title
        ret += "pub_time = %s\n" % self.pub_time
        return ret

    def __str__ (self):
        return self.__repr__ ()


class NoteList:
    
    author_id = ""
    cur_page = -1

    nlist = []

    def __init__ (self, author_id = None, cur_page = None):
        self.author_id = author_id
        self.cur_page = cur_page
        self.nlist = []

    def __repr__ (self):
        ret = ""
        ret += "author_id = %s\n" % self.author_id
        ret += "cur_page = %s\n" % self.cur_page
        for i, note in zip(xrange (len (self.nlist)), self.nlist):
            ret += " " * 12 + "****** [%dth note] ******\n" % i
            ret += "%s\n" % str (note)
        return ret

    def __str__ (self):
        return self.__repr__ ()

    def addNote (self, note):
        self.nlist.append (note)

    def __len__ (self):
        return len (self.nlist)

    def __getitem__ (self, index):
        return self.nlist[index]


class Note:

    author_id = ""
    note_id = ""
    title = ""
    pub_time = ""
    content = ""
    
    def __init__ (self, author_id = None, note_id = None, title = None, 
                    pub_time = None, content = None):
        self.author_id = author_id
        self.note_id = note_id
        self.title = title
        self.pub_time = pub_time
        self.content = content

    def __repr__ (self):
        ret = ""
        ret += "author_id = %s\n" % self.author_id
        ret += "note_id = %s\n" % self.note_id
        ret += "title = %s\n" % self.title
        ret += "pub_time = %s\n" % self.pub_time
        ret += "content = %s\n" % self.content
        return ret

    def __str__ (self):
        return self.__repr__ ()

